import 'package:flutter/material.dart';

void main() {
  // 1. 运行应用程序
  //    MaterialApp  主题
  //    Scaffold     脚手架
  //    AppBar       顶部标题栏
  runApp(MaterialApp(home: MyApp()));
}

class MyApp extends StatelessWidget {
  MyApp({super.key, this.age = 18});
  // 需要用 final 修饰
  int age;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("无状态组件"),
        backgroundColor: Colors.purple,
      ),
      body: Center(
        child: Text('我今年$age岁了'),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          age++;
          debugPrint('点击了按钮$age');
        },
        child: const Icon(Icons.add),
      ),
    );
  }
}
